<template>
  <view class="content">
    <image class="logo" src="/static/logo.png"></image>
    <view class="text-area">
      <button type="default" @click="goto">通过方法跳转到home页面</button>
      <button type="default" @click="getRequest">get请求</button>
      <button type="default" @click="postRequest">put请求</button>
    </view>
  </view>
</template>
<script>
export default {
  data() {
    return {
      title: 'Hello world!!'
    }
  },
  onLoad() {
  },
  methods: {
    goto(url) {
      uni.navigateTo({
        url: "/pages/njt/home"
      });
    },
    getRequest() {
      uni.request({
        url: 'http://localhost:8080/nongjt/userRegister/list', //仅为示例，并非真实接口地址。
        method: 'get',
        data: {
          pageNum: 1,
          pageSize: 5
        },
        success: (res) => {
          console.log(res.data);
        }
      });
    },
    postRequest() {
      uni.request({

        url: 'http://localhost:8080/nongjt/UserRegister', //仅为示例，并非真实接口地址。
        method: 'put',
        data: {
          "id": 29,
          "companyName": "companyName_2ac5792c47d8",
          "mobilePhone": "mobilePhone_39f699fd355f",
          "password": "password_530411d70e62",
          "registerTime": "2025-09-23 11:31:53"
        },
        header: {
          'content-type': 'application/json' //自定义请求头信息
        },
        success: (res) => {
          console.log(res.data);
        }
      });
    }
  }
}
</script>
<style>
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.logo {
  height: 200rpx;
  width: 200rpx;
  margin-top: 200rpx;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 50rpx;
}

.text-area {
  display: flex;
  justify-content: center;
}

.title {
  font-size: 36rpx;
  color: #8f8f94;
}
</style>